<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>ncepgrib2.Grib2Encode</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="ncepgrib2-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="ncepgrib2-module.html">Module&nbsp;ncepgrib2</a> ::
        Class&nbsp;Grib2Encode
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Grib2Encode</h1><p class="nomargin-top"><span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode">source&nbsp;code</a></span></p>
<p>Class for encoding data into a GRIB2 message.</p>
  <ul>
    <li>
      Creating a class instance (<a 
      href="ncepgrib2.Grib2Encode-class.html#__init__" 
      class="link">__init__</a>) initializes the message and adds sections 
      0 and 1 (the indicator and identification sections),
    </li>
    <li>
      method <a href="ncepgrib2.Grib2Encode-class.html#addgrid" 
      class="link">addgrid</a> adds a grid definition (section 3) to the 
      messsage.
    </li>
    <li>
      method <a href="ncepgrib2.Grib2Encode-class.html#addfield" 
      class="link">addfield</a> adds sections 4-7 to the message (the 
      product definition, data representation, bitmap and data sections).
    </li>
    <li>
      method <a href="ncepgrib2.Grib2Encode-class.html#end" 
      class="link">end</a> adds the end section (section 8) and terminates 
      the message.
    </li>
  </ul>
  <p>A GRIB Edition 2 message is a machine independent format for storing 
  one or more gridded data fields.  Each GRIB2 message consists of the 
  following sections:</p>
  <ul>
    <li>
      SECTION 0: Indicator Section - only one per message
    </li>
    <li>
      SECTION 1: Identification Section - only one per message
    </li>
    <li>
      SECTION 2: (Local Use Section) - optional
    </li>
    <li>
      SECTION 3: Grid Definition Section
    </li>
    <li>
      SECTION 4: Product Definition Section
    </li>
    <li>
      SECTION 5: Data Representation Section
    </li>
    <li>
      SECTION 6: Bit-map Section
    </li>
    <li>
      SECTION 7: Data Section
    </li>
    <li>
      SECTION 8: End Section
    </li>
  </ul>
  <p>Sequences of GRIB sections 2 to 7, 3 to 7, or sections 4 to 7 may be 
  repeated within a single GRIB message.  All sections within such repeated
  sequences must be present and shall appear in the numerical order noted 
  above. Unrepeated sections remain in effect until redefined.</p>
  <p>Note:  Writing section 2 (the 'local use section') is not yet 
  supported.</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Instance Methods</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="ncepgrib2.Grib2Encode-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">discipline</span>,
        <span class="summary-sig-arg">idsect</span>)</span><br />
      create a Grib2Enecode class instance given the GRIB2 discipline 
      parameter and the identification section (sections 0 and 1).</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="ncepgrib2.Grib2Encode-class.html#addfield" class="summary-sig-name">addfield</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">pdtnum</span>,
        <span class="summary-sig-arg">pdtmpl</span>,
        <span class="summary-sig-arg">drtnum</span>,
        <span class="summary-sig-arg">drtmpl</span>,
        <span class="summary-sig-arg">field</span>,
        <span class="summary-sig-arg">coordlist</span>=<span class="summary-sig-default">None</span>)</span><br />
      Add a product definition section, data representation section, bitmap
      section and data section to the GRIB2 message (sections 4-7).</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.addfield">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="ncepgrib2.Grib2Encode-class.html#addgrid" class="summary-sig-name">addgrid</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">gdsinfo</span>,
        <span class="summary-sig-arg">gdtmpl</span>,
        <span class="summary-sig-arg">deflist</span>=<span class="summary-sig-default">None</span>)</span><br />
      Add a grid definition section (section 3) to the GRIB2 message.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.addgrid">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="ncepgrib2.Grib2Encode-class.html#end" class="summary-sig-name">end</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Add an end section (section 8) to the GRIB2 message.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.end">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== INSTANCE VARIABLES ==================== -->
<a name="section-InstanceVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Instance Variables</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="ncepgrib2.Grib2Encode-class.html#msg" class="summary-name">msg</a><br />
      A binary string containing the GRIB2 message.
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Method Details</span></td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">discipline</span>,
        <span class="sig-arg">idsect</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>create a Grib2Enecode class instance given the GRIB2 discipline 
  parameter and the identification section (sections 0 and 1).</p>
  <p>The GRIB2 message is stored as a binary string in instance variable <a
  href="ncepgrib2.Grib2Encode-class.html#msg" class="link">msg</a>.</p>
  <p><a href="ncepgrib2.Grib2Encode-class.html#addgrid" 
  class="link">addgrid</a>, <a 
  href="ncepgrib2.Grib2Encode-class.html#addfield" 
  class="link">addfield</a> and <a 
  href="ncepgrib2.Grib2Encode-class.html#end" class="link">end</a> class 
  methods must be called to complete the GRIB2 message.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>discipline</code></strong> - Discipline or GRIB Master Table Number (Code Table 0.0). (0 for 
          meteorlogical, 1 for hydrological, 2 for land surface, 3 for 
          space, 10 for oceanographic products).</li>
        <li><strong class="pname"><code>idsect</code></strong> - Sequence containing identification section (section 1).
          <ul>
            <li>
              idsect[0]=Id of orginating centre (Common Code <a 
              href="http://www.nws.noaa.gov/tg/GRIB_C1.htm" 
              target="_top">Table C-1</a>)
            </li>
            <li>
              idsect[1]=Id of orginating sub-centre (local table)
            </li>
            <li>
              idsect[2]=GRIB Master Tables Version Number (Code <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table1-0.shtml"
              target="_top">Table 1.0</a>)
            </li>
            <li>
              idsect[3]=GRIB Local Tables Version Number (Code <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table1-1.shtml"
              target="_top">Table 1.1</a>)
            </li>
            <li>
              idsect[4]=Significance of Reference Time (Code <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table1-2.shtml"
              target="_top">Table 1.2</a>)
            </li>
            <li>
              idsect[5]=Reference Time - Year (4 digits)
            </li>
            <li>
              idsect[6]=Reference Time - Month
            </li>
            <li>
              idsect[7]=Reference Time - Day
            </li>
            <li>
              idsect[8]=Reference Time - Hour
            </li>
            <li>
              idsect[9]=Reference Time - Minute
            </li>
            <li>
              idsect[10]=Reference Time - Second
            </li>
            <li>
              idsect[11]=Production status of data (Code <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table1-3.shtml"
              target="_top">Table 1.3</a>)
            </li>
            <li>
              idsect[12]=Type of processed data (Code <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table1-4.shtml"
              target="_top">Table 1.4</a>)
            </li>
          </ul></li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="addfield"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">addfield</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">pdtnum</span>,
        <span class="sig-arg">pdtmpl</span>,
        <span class="sig-arg">drtnum</span>,
        <span class="sig-arg">drtmpl</span>,
        <span class="sig-arg">field</span>,
        <span class="sig-arg">coordlist</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.addfield">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add a product definition section, data representation section, bitmap 
  section and data section to the GRIB2 message (sections 4-7). Must be 
  called after grid definition section is created with <a 
  href="ncepgrib2.Grib2Encode-class.html#addgrid" 
  class="link">addgrid</a>.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>pdtnum</code></strong> - Product Definition Template Number (see Code <a 
          href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table4-0.shtml"
          target="_top">Table 4.0</a>)</li>
        <li><strong class="pname"><code>pdtmpl</code></strong> - Sequence with the data values for the specified Product 
          Definition Template (N=pdtnum).  Each element of this integer 
          array contains an entry (in the order specified) of Product 
          Definition Template 4.N</li>
        <li><strong class="pname"><code>drtnum</code></strong> - Data Representation Template Number (see Code <a 
          href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table5-0.shtml"
          target="_top">Table 5.0</a>)</li>
        <li><strong class="pname"><code>drtmpl</code></strong> - Sequence with the data values for the specified Data 
          Representation Template (N=drtnum).  Each element of this integer
          array contains an entry (in the order specified) of Data 
          Representation Template 5.N Note that some values in this 
          template (eg. reference values, number of bits, etc...) may be 
          changed by the data packing algorithms. Use this to specify 
          scaling factors and order of spatial differencing, if desired.</li>
        <li><strong class="pname"><code>field</code></strong> - numpy array of data points to pack. If field is a masked array, 
          then a bitmap is created from the mask.</li>
        <li><strong class="pname"><code>coordlist</code></strong> - Sequence containing floating point values intended to document 
          the vertical discretization with model data on hybrid coordinate 
          vertical levels. Default None.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="addgrid"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">addgrid</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">gdsinfo</span>,
        <span class="sig-arg">gdtmpl</span>,
        <span class="sig-arg">deflist</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.addgrid">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add a grid definition section (section 3) to the GRIB2 message.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>gdsinfo</code></strong> - Sequence containing information needed for the grid definition 
          section.
          <ul>
            <li>
              gdsinfo[0] = Source of grid definition (see Code <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table3-0.shtml"
              target="_top">Table 3.0</a>)
            </li>
            <li>
              gdsinfo[1] = Number of grid points in the defined grid.
            </li>
            <li>
              gdsinfo[2] = Number of octets needed for each additional grid
              points defn. Used to define number of points in each row for 
              non-reg grids (=0 for regular grid).
            </li>
            <li>
              gdsinfo[3] = Interp. of list for optional points defn (Code 
              <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table3-11.shtml"
              target="_top">Table 3.11</a>)
            </li>
            <li>
              gdsinfo[4] = Grid Definition Template Number (Code <a 
              href="http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_table3-1.shtml"
              target="_top">Table 3.1</a>)
            </li>
          </ul></li>
        <li><strong class="pname"><code>gdtmpl</code></strong> - Contains the data values for the specified Grid Definition 
          Template ( NN=gdsinfo[4] ).  Each element of this integer array 
          contains an entry (in the order specified) of Grid Definition 
          Template 3.NN</li>
        <li><strong class="pname"><code>deflist</code></strong> - (Used if gdsinfo[2] != 0)  Sequence containing the number of grid
          points contained in each row (or column) of a non-regular grid.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="end"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">end</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="ncepgrib2-pysrc.html#Grib2Encode.end">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add an end section (section 8) to the GRIB2 message. A GRIB2 message 
  is not complete without an end section. Once an end section is added, the
  GRIB2 message can be output to a file.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== INSTANCE VARIABLE DETAILS ==================== -->
<a name="section-InstanceVariableDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Instance Variable Details</span></td>
</tr>
</table>
<a name="msg"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">msg</h3>
  A binary string containing the GRIB2 message. After the message has been 
  terminated by calling the <a href="ncepgrib2.Grib2Encode-class.html#end" 
  class="link">end</a> method, this string can be written to a file.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="ncepgrib2-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Dec 29 14:23:16 2014
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
